﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SharpSoft.Net.P2P.NatModels
{
    public struct PeerInfo : IComparable
    {
        public string AppName { get; set; }

        public string DeviceId { get; set; }

        public override string ToString()
        {
            return $"{AppName} {DeviceId}";
        }
        public override bool Equals(object obj)
        {
            if (obj is PeerInfo pi)
            {
                return pi.AppName == this.AppName && pi.DeviceId == this.DeviceId;
            }
            return false;
        }
        public int CompareTo(object obj)
        {
            return this.Equals(obj) ? 0 : 1;
        }

        public override int GetHashCode()
        {
            var hashCode = -1024003523;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(AppName);
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(DeviceId);
            return hashCode;
        }
    }
}
